<?php
/**
 * Created by PhpStorm.
 * User: lixy
 * Date: 2016/1/6
 * Time: 9:15
 */


use yii\helpers\Url;

$imgUrl = Url::to("@web/img/wx/");
$jsUrl = Url::to("@web/js/wx/");
$basejsUrl = Url::to("@web/js/");
$cssUrl = Url::to("@web/css/wx/");

?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <link rel="stylesheet" href="<?= $cssUrl ?>weui.css"/>
    <link rel="stylesheet" href="<?= $cssUrl ?>send_gift_record_choice.css"/>
    <script src="<?= $jsUrl ?>zepto.min.js"></script>
    <script src="<?= $basejsUrl ?>jquery.js"></script>
    <script src="<?=$basejsUrl?>/tools.js"></script>
    <script type="application/javascript">
        $(document).ready(function () {
            var headerHeight = $(".header-year").height() + parseInt($(".header-year").css("padding-top"));
            var h = $(window).height();
            $(".main-content").height(h - headerHeight);
            $(".main-content .date-frame").height(h - headerHeight);

            ///初始化
            $(".filter-item").removeClass("filter-item-selected");
           var status=$("#hidden_status").val();
            $("#btn"+status).addClass("filter-item-selected");
            //显示第一张

            $(".date-item:eq(0)").click();

        });
        function hrefLink(status){
            window.location.href="<?=Url::to(["wx-biz/send-gift-record-choice"]);?>?status="+status;
        }
        function hrefExchange_card(){
            var id=$(".date-item-selected").attr("card_code_id");
//            window.location.href="<?//=Url::to(["wx-biz/exchange-card-nav"]);?>//?id="+id;
            window.location.href="<?=Url::to(["wx-biz/gift-receive-detail"]);?>?id="+id;
        }
        function switchCard(me,cardid,orderid,status){
//            debugger;
            $("#div_card").hide();
            $(".date-item").removeClass("date-item-selected");
            var data={};
            data.cardid=cardid;
            data.orderid=orderid;
            var re=returnjson("<?=Url::to(["wx-biz/show-buy-card-handle"])?>",data);
            if(re.flag==1){
//                赋值
                $(".card-name").html(re.card.NAME);
                $(".card-price").html(re.card.PRICE);
                if(status==1)
                    $(".card-valid").html("有效期还剩"+re.day_count+"天");
                if(status==2)
                    $(".card-valid").html("已兑换");
                if(status==3)
                    $(".card-valid").html("已过期");
                if(status==4)
                    $(".card-valid").html("已失效");
                //$(".send-count").html("赠出 x"+re.count);

                $(me).addClass("date-item-selected");
                $("#div_card").show();

            }else{
                alert(re.msg);
            };
        }

    </script>
    <title>收礼记录</title>
</head>
<body>
<input type="hidden" id="hidden_status" value="<?=$status?>"/>
<div class="main">
    <div class="header-year">2016</div>
    <table class="main-content" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="date-td" valign="top">
                <div class="date-frame">
                    <div class="date-content">
                        <?php

                        for($i = 0; $i < sizeof($myCards); ++$i) {
                            $CREATE_DATETIME_SHOW=$myCards[$i]['CREATE_DATETIME_SHOW'];
                            $card_id=$myCards[$i]['CARD_ID'];
                            $order_id=$myCards[$i]['ORDER_ID'];
                            $card_code_id=$myCards[$i]['CARD_CODE_ID'];
                            $status=$myCards[$i]['STATUS'];
                            if($i==0){
                                echo "<div class=\"date-item date-item-selected\" card_code_id='$card_code_id' onclick='switchCard(this,\"$card_id\",\"$order_id\",$status)'>$CREATE_DATETIME_SHOW</div>";
                            }else{
                                echo "<div class=\"date-item\" card_code_id='$card_code_id' onclick='switchCard(this,\"$card_id\",\"$order_id\",$status)'>$CREATE_DATETIME_SHOW</div>";
                            }
                        }
                        ?>


                        <!--<div class="date-item">11-11</div>
                        <div class="date-item date-item-selected">11-11</div>-->

                    </div>
                </div>
            </td>
            <td style="width: 1px;">
                <div style="width: 1px; height: 100%; background-color: #727584;"></div>
            </td>
            <td>
                <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">
                    <tr>
                        <td colspan="3">
                            <div class="card-bg-frame">
                                <table id="div_card" onclick="hrefExchange_card()" cellpadding="0" cellspacing="0" border="0" class="card-frame" style="display: none;">
                                    <tr style="height: 50px;">
                                        <td>
                                            <div class="card-logo"></div>
                                        </td>
                                        <td class="card-valid" valign="bottom">有效期还剩100天</td>
                                        <td class="card-price-symbol" valign="bottom" style="display: none;">¥</td>
                                        <td class="card-price" valign="bottom" style="display: none;">199</td>
                                    </tr>
                                    <tr style="height: 20px;">
                                        <td colspan="4">
                                            <div style="border-bottom: 1px #000000 dashed;"></div>
                                        </td>
                                    </tr>
                                    <tr style="height: 20px;">
                                        <td colspan="4">
                                            <div class="card-name">春节合家欢卡</div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="filter-item" id="btn0" onclick="hrefLink(0);">全部</div>
                        </td>
                        <td>
                            <div class="filter-item filter-item-selected" id="btn2" onclick="hrefLink(2);">已兑换</div>
                        </td>
                        <td>
                            <div class="filter-item" id="btn1" onclick="hrefLink(1);">未兑换</div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

</body>
</html>
